import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

Vue.config.productionTip = false;

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);


//引入vant组件
import Vant from 'vant';
import 'vant/lib/index.css';
Vue.use(Vant);

//折线图
import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts;

// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)


import axios from './http';//开启路由拦截器
// import axios from 'axios';//导入axios对象

// 拦截器的配置一定要在实例挂在之前
// axios.interceptors.request.use(
// 有两个回调 请求成功 请求失败
// (config) => {
// config是我们请求配置文件，当我们做完一些事情后一定要将config return
//我们设置一些请求头的信息，或者数据提示
// return config;
// },
// (error) => {
// return Promise.reject(error)
// }
// )

//响应拦截
axios.interceptors.response.use(
  //res就是我们等到的数据
  (res) => {
    return res.data;//拦截到data里面的数据
  },
  (error) => {
    console.log(error);
  }
)

Vue.prototype.$http = axios;

import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload, {
  prreLoad: 1.3,//距离当前页面底部的高度
  error: '',//加载失败现实的图片
  loading: '',//加载中显示的图片
  attempt: 1,//加载失败，最最多重试的次数
});


Vue.filter('time', function (val) {
  let now = new Date(val)
  var Y = now.getFullYear()
  var M = now.getMonth() + 1
  var D = now.getDate()
  var H = now.getHours() + ''
  H = H.padStart(2, 0)
  var m = now.getMinutes() + ''
  m = m.padStart(2, 0)
  var s = now.getSeconds() + ''
  s = s.padStart(2, 0)
  return ` ${Y}-${M}-${D} ${H}:${m}:${s}`
})
new Vue({
  router,
  store,
  render: h => h(App), data: { eventHub: new Vue() }
}).$mount("#app");
